package com.shujia.hdfs;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

import java.io.IOException;

public class Demo02CopyFromLocalFile {
    public static void main(String[] args) throws IOException {

        // 上传文件：copyFromLocalFile
        // 建立连接
        Configuration conf = new Configuration();
        conf.set("fs.defaultFS","hdfs://master:9000");
        FileSystem fs = FileSystem.get(conf);

        // 类似的 moveFromLocalFile，上传完成后会删除本地文件
        fs.copyFromLocalFile(new Path("hadoop/data/words.txt"),new Path("/user/root/"));
        System.out.println("文件上传完毕");
    }
}
